from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models
from django.urls import reverse


# 用户信息model 定义
class Users(models.Model):
    name = models.CharField(max_length=30,verbose_name="姓名")
    no = models.CharField(max_length=10,verbose_name="昵称")
    gender = models.CharField(max_length=10, choices=[('男', '男'), ('女', '女')])
    age = models.IntegerField(verbose_name="年龄")
    profession = models.CharField(max_length=30,verbose_name="职业")


    def __str__(self) -> str:
        return self.name

    class Meta:
        db_table = "users"
        managed = True
        verbose_name = "用户表"
        verbose_name_plural = verbose_name
        unique_together = ['no']
        # 可以在这里添加额外的验证逻辑，例如：
        # extra_kwargs = {
        #     'age': {'validators': [MinValueValidator(1), MaxValueValidator(1)]}
        # }
